package com.ldj.hibernate;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;

/**
 * Data access object (DAO) for domain model class TTest.
 * 
 * @see com.ldj.hibernate.TTest
 * @author MyEclipse Persistence Tools
 */

public class UnitUserRegisterDAO extends BaseHibernateDAO {
	public UnitUserRegisterDAO(HttpServletRequest request, HttpServletResponse response) {
		super(request, response);
		// TODO Auto-generated constructor stub
	}
	private static final Log log = LogFactory.getLog(TTestDAO.class);	
	
	public void save(UnitUser userInfo) {
		log.debug("saving UnitUser instance");
		try {
			getSession().save(userInfo);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	public List findAllfromLoginName(String loginName) {
		log.debug("finding all UnitUser instances");
		try {
			String queryString = "from UnitUser where unitUserLoginName='" + loginName + "'";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	
}